using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Diagnostics;
using System.Runtime.Remoting.Messaging;
using System.ServiceProcess;
using System.Windows.Forms;

using FreeFlow.Administration;

namespace FreeFlowAdministrator
{
	/// <summary>
	/// Summary description for RegistrySettingsControl.
	/// </summary>
	public class RegistrySettingsControl : System.Windows.Forms.UserControl
	{
    private System.Windows.Forms.PictureBox pictureBox1;
    private FreeFlowAdministrator.UIActionsControl uiActionsControl;
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.NumericUpDown scriptTimeoutTextBox;
    private System.Windows.Forms.Label label2;
		/// <summary> 
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
    private System.Windows.Forms.Label label3;
    private System.Windows.Forms.NumericUpDown jscriptNetTimeoutTextBox;
    private System.Windows.Forms.Label label4;
    private System.Windows.Forms.CheckBox activateCallerIdCheckBox;
    private System.Windows.Forms.Label label5;
    private System.Windows.Forms.NumericUpDown queryTimeoutTextBox;
    private System.Windows.Forms.Label label6;
    private System.Windows.Forms.Label label7;
    private System.Windows.Forms.NumericUpDown loginTimeoutTextBox;
    private System.Windows.Forms.Label label8;
    private System.Windows.Forms.CheckBox forceCaseSensitiveRolesCheckBox;
    private System.Windows.Forms.CheckBox forceCaseSensitiveAuthenticationCheckBox;
    private System.Windows.Forms.CheckBox fireWhenchangedOnSubmitCheckBox;
    private System.Windows.Forms.CheckBox staticRoleResolutionCheckBox;
    private System.Windows.Forms.NumericUpDown asyncJobsTextBox;
    private System.Windows.Forms.Label label9;
    private System.Windows.Forms.CheckBox allowGuestUserToRaiseFlagCheckBox;
    private System.Windows.Forms.Label label10;
    private System.Windows.Forms.TextBox engineNameTextBox;
    private System.Windows.Forms.Label label11;
    private System.Windows.Forms.TextBox baseUrlTextBox;
    private System.Windows.Forms.CheckBox logToFileCheckBox;
    private System.Windows.Forms.Label label12;
    private System.Windows.Forms.TextBox eventLogFileTextBox;
    private System.Windows.Forms.CheckBox precompileCheckBox;
    private System.Windows.Forms.Label infoLabel;
    private System.Windows.Forms.Label engineStatusLabel;

    private RegistrySettings registrySettings;
    private Label label13;
    private NumericUpDown wfTimeoutTextBox;
    private Label label14;
    private Label alertGeneratorThreadLabel;
    private NumericUpDown alertGeneratorPollInterval;
    private Label alertGeneratorPollLabel;
    private CheckBox alertGeneratorEnabled;
    private NumericUpDown alertGeneratorBatchSize;
    private Label alertGeneratorBatchLabel;
    private NumericUpDown alertGeneratorThreadCount;
    private NumericUpDown eventManagerThreadCount;
    private Label eventManagerThreadLabel;
    private NumericUpDown eventManagerPollInterval;
    private Label eventManagerPollLabel;
    private CheckBox eventManagerEnabled;
    private NumericUpDown eventManagerBatchSize;
    private Label eventManagerBatchLabel;
    private DevExpress.XtraEditors.XtraScrollableControl xtraScrollableControl1;
    private GroupBox groupControl1;
    private GroupBox groupControl3;
    private GroupBox groupControl2;
    private Label label15;
    private TextBox emailConnectionString;
    private ServiceController engineService;
    public RegistrySettingsControl()
    {
      // This call is required by the Windows.Forms Form Designer.
      InitializeComponent();

      // find the engine service
      ServiceController[] services = ServiceController.GetServices();
      foreach(ServiceController svc in services)
      {
        if ((svc.ServiceName == "e-Work Engine") || (svc.ServiceName == "Metastorm Process Engine"))
        {
          engineService = svc;
          break;
        }
      }

      ShowEngineStatus();

      UpdateActions();

      registrySettings = new RegistrySettings();
      try
      {
        scriptTimeoutTextBox.Value = registrySettings.ScriptTimeout;
        jscriptNetTimeoutTextBox.Value = registrySettings.JScriptNetScriptTimeout;
        activateCallerIdCheckBox.Checked = registrySettings.ActivateCallerId;
        queryTimeoutTextBox.Value = registrySettings.QueryTimeout;
        loginTimeoutTextBox.Value = registrySettings.LoginTimeout;
        forceCaseSensitiveAuthenticationCheckBox.Checked = registrySettings.CaseSensitiveAuthentication;
        forceCaseSensitiveRolesCheckBox.Checked = registrySettings.CaseSensitiveRoleEvaluation;
        fireWhenchangedOnSubmitCheckBox.Checked = registrySettings.FireWhenChangedOnSubmit;
        staticRoleResolutionCheckBox.Checked = registrySettings.StaticRoleResolution;
        asyncJobsTextBox.Value = registrySettings.MaximumSimultaneousAsynchronousJobs;
        allowGuestUserToRaiseFlagCheckBox.Checked = registrySettings.AllowGuestUserToRaiseFlag;
        engineNameTextBox.Text = registrySettings.EngineName;
        baseUrlTextBox.Text = registrySettings.BaseUrl;
        precompileCheckBox.Checked = registrySettings.PrecompileJScriptNet;
        wfTimeoutTextBox.Value = registrySettings.WorkflowTimeout;
        emailConnectionString.Text = registrySettings.EmailConnectionString;

        // log file
        logToFileCheckBox.Checked = registrySettings.LogEventLogEntriesToFile;
        eventLogFileTextBox.Text = registrySettings.LogFile;
        EnableLogTextBox();

        // event manager
        eventManagerEnabled.Checked = registrySettings.EventManagerEnabled;
        eventManagerBatchSize.Value = registrySettings.EventManagerBatchSize;
        eventManagerPollInterval.Value = registrySettings.EventManagerPollInterval;
        eventManagerThreadCount.Value = registrySettings.EventManagerThreadCount;
        EnableEventManager();
        
        // alert generator
        alertGeneratorEnabled.Checked = registrySettings.AlertGeneratorEnabled;
        alertGeneratorBatchSize.Value = registrySettings.AlertGeneratorBatchSize;
        alertGeneratorPollInterval.Value = registrySettings.AlertGeneratorPollInterval;
        alertGeneratorThreadCount.Value = registrySettings.AlertGeneratorThreadCount;
        EnableAlertGenerator();
      }
      catch(System.Security.SecurityException)
      {
        infoLabel.Text = "Unable to access one or more registry keys on the local machine. Check your access rights";
        Font font = new Font(infoLabel.Font, FontStyle.Bold);
        infoLabel.Font = font;
        Enabled = false;
      }
    }

    private void UpdateActions()
    {
      UIActionList actionList = new UIActionList();
      actionList.Add("Apply changes", "Apply any changes made. Some of these changes may require a restart of the engine", 
        new ActionExecuteDelegate(ApplyChanges));
      if ((engineService != null) && (engineService.Status == ServiceControllerStatus.Stopped))
        actionList.Add("Start engine", "Start the engine on this machine", 
          new ActionExecuteDelegate(StartEngine));
      if ((engineService != null) && (engineService.Status == ServiceControllerStatus.Running))
        actionList.Add("Stop engine", "Stop the engine on this machine", 
          new ActionExecuteDelegate(StopEngine));
      actionList.Add("Run RegEdit", "Modify engine settings directly through the registry", 
        new ActionExecuteDelegate(RunRegEdit));
      actionList.Add("Run Event Viewer", "View engine messages written to the event log", 
        new ActionExecuteDelegate(RunEventViewer));
      uiActionsControl.Actions = actionList;
    }

    private void ShowEngineStatus()
    {
      // engine status
      if (engineService == null)
        engineStatusLabel.Text = "Engine status: No engine found";
      else
        engineStatusLabel.Text = "Engine status: " + engineService.Status.ToString();
		}

		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Component Designer generated code
		/// <summary> 
		/// Required method for Designer support - do not modify 
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RegistrySettingsControl));
      this.pictureBox1 = new System.Windows.Forms.PictureBox();
      this.label1 = new System.Windows.Forms.Label();
      this.scriptTimeoutTextBox = new System.Windows.Forms.NumericUpDown();
      this.label2 = new System.Windows.Forms.Label();
      this.label3 = new System.Windows.Forms.Label();
      this.jscriptNetTimeoutTextBox = new System.Windows.Forms.NumericUpDown();
      this.label4 = new System.Windows.Forms.Label();
      this.activateCallerIdCheckBox = new System.Windows.Forms.CheckBox();
      this.label5 = new System.Windows.Forms.Label();
      this.queryTimeoutTextBox = new System.Windows.Forms.NumericUpDown();
      this.label6 = new System.Windows.Forms.Label();
      this.label7 = new System.Windows.Forms.Label();
      this.loginTimeoutTextBox = new System.Windows.Forms.NumericUpDown();
      this.label8 = new System.Windows.Forms.Label();
      this.forceCaseSensitiveAuthenticationCheckBox = new System.Windows.Forms.CheckBox();
      this.forceCaseSensitiveRolesCheckBox = new System.Windows.Forms.CheckBox();
      this.fireWhenchangedOnSubmitCheckBox = new System.Windows.Forms.CheckBox();
      this.staticRoleResolutionCheckBox = new System.Windows.Forms.CheckBox();
      this.asyncJobsTextBox = new System.Windows.Forms.NumericUpDown();
      this.label9 = new System.Windows.Forms.Label();
      this.allowGuestUserToRaiseFlagCheckBox = new System.Windows.Forms.CheckBox();
      this.label10 = new System.Windows.Forms.Label();
      this.engineNameTextBox = new System.Windows.Forms.TextBox();
      this.label11 = new System.Windows.Forms.Label();
      this.baseUrlTextBox = new System.Windows.Forms.TextBox();
      this.logToFileCheckBox = new System.Windows.Forms.CheckBox();
      this.label12 = new System.Windows.Forms.Label();
      this.eventLogFileTextBox = new System.Windows.Forms.TextBox();
      this.precompileCheckBox = new System.Windows.Forms.CheckBox();
      this.infoLabel = new System.Windows.Forms.Label();
      this.engineStatusLabel = new System.Windows.Forms.Label();
      this.label13 = new System.Windows.Forms.Label();
      this.wfTimeoutTextBox = new System.Windows.Forms.NumericUpDown();
      this.label14 = new System.Windows.Forms.Label();
      this.alertGeneratorBatchLabel = new System.Windows.Forms.Label();
      this.alertGeneratorBatchSize = new System.Windows.Forms.NumericUpDown();
      this.alertGeneratorEnabled = new System.Windows.Forms.CheckBox();
      this.alertGeneratorPollLabel = new System.Windows.Forms.Label();
      this.alertGeneratorPollInterval = new System.Windows.Forms.NumericUpDown();
      this.alertGeneratorThreadLabel = new System.Windows.Forms.Label();
      this.alertGeneratorThreadCount = new System.Windows.Forms.NumericUpDown();
      this.eventManagerThreadCount = new System.Windows.Forms.NumericUpDown();
      this.eventManagerThreadLabel = new System.Windows.Forms.Label();
      this.eventManagerPollInterval = new System.Windows.Forms.NumericUpDown();
      this.eventManagerPollLabel = new System.Windows.Forms.Label();
      this.eventManagerEnabled = new System.Windows.Forms.CheckBox();
      this.eventManagerBatchSize = new System.Windows.Forms.NumericUpDown();
      this.eventManagerBatchLabel = new System.Windows.Forms.Label();
      this.xtraScrollableControl1 = new DevExpress.XtraEditors.XtraScrollableControl();
      this.groupControl3 = new System.Windows.Forms.GroupBox();
      this.groupControl2 = new System.Windows.Forms.GroupBox();
      this.groupControl1 = new System.Windows.Forms.GroupBox();
      this.label15 = new System.Windows.Forms.Label();
      this.emailConnectionString = new System.Windows.Forms.TextBox();
      this.uiActionsControl = new FreeFlowAdministrator.UIActionsControl();
      ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
      ((System.ComponentModel.ISupportInitialize)(this.scriptTimeoutTextBox)).BeginInit();
      ((System.ComponentModel.ISupportInitialize)(this.jscriptNetTimeoutTextBox)).BeginInit();
      ((System.ComponentModel.ISupportInitialize)(this.queryTimeoutTextBox)).BeginInit();
      ((System.ComponentModel.ISupportInitialize)(this.loginTimeoutTextBox)).BeginInit();
      ((System.ComponentModel.ISupportInitialize)(this.asyncJobsTextBox)).BeginInit();
      ((System.ComponentModel.ISupportInitialize)(this.wfTimeoutTextBox)).BeginInit();
      ((System.ComponentModel.ISupportInitialize)(this.alertGeneratorBatchSize)).BeginInit();
      ((System.ComponentModel.ISupportInitialize)(this.alertGeneratorPollInterval)).BeginInit();
      ((System.ComponentModel.ISupportInitialize)(this.alertGeneratorThreadCount)).BeginInit();
      ((System.ComponentModel.ISupportInitialize)(this.eventManagerThreadCount)).BeginInit();
      ((System.ComponentModel.ISupportInitialize)(this.eventManagerPollInterval)).BeginInit();
      ((System.ComponentModel.ISupportInitialize)(this.eventManagerBatchSize)).BeginInit();
      this.xtraScrollableControl1.SuspendLayout();
      this.groupControl3.SuspendLayout();
      this.groupControl2.SuspendLayout();
      this.groupControl1.SuspendLayout();
      this.SuspendLayout();
      // 
      // pictureBox1
      // 
      this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
      this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
      this.pictureBox1.Location = new System.Drawing.Point(626, 9);
      this.pictureBox1.Name = "pictureBox1";
      this.pictureBox1.Size = new System.Drawing.Size(32, 32);
      this.pictureBox1.TabIndex = 33;
      this.pictureBox1.TabStop = false;
      // 
      // label1
      // 
      this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.label1.Location = new System.Drawing.Point(6, 16);
      this.label1.Name = "label1";
      this.label1.Size = new System.Drawing.Size(176, 16);
      this.label1.TabIndex = 34;
      this.label1.Text = "JScript and VBScript timeout:";
      // 
      // scriptTimeoutTextBox
      // 
      this.scriptTimeoutTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.scriptTimeoutTextBox.Location = new System.Drawing.Point(223, 14);
      this.scriptTimeoutTextBox.Maximum = new decimal(new int[] {
            100000,
            0,
            0,
            0});
      this.scriptTimeoutTextBox.Name = "scriptTimeoutTextBox";
      this.scriptTimeoutTextBox.Size = new System.Drawing.Size(64, 20);
      this.scriptTimeoutTextBox.TabIndex = 36;
      // 
      // label2
      // 
      this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.label2.Location = new System.Drawing.Point(293, 16);
      this.label2.Name = "label2";
      this.label2.Size = new System.Drawing.Size(48, 16);
      this.label2.TabIndex = 37;
      this.label2.Text = "seconds";
      // 
      // label3
      // 
      this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.label3.Location = new System.Drawing.Point(293, 40);
      this.label3.Name = "label3";
      this.label3.Size = new System.Drawing.Size(48, 16);
      this.label3.TabIndex = 40;
      this.label3.Text = "seconds";
      // 
      // jscriptNetTimeoutTextBox
      // 
      this.jscriptNetTimeoutTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.jscriptNetTimeoutTextBox.Location = new System.Drawing.Point(223, 38);
      this.jscriptNetTimeoutTextBox.Maximum = new decimal(new int[] {
            100000,
            0,
            0,
            0});
      this.jscriptNetTimeoutTextBox.Name = "jscriptNetTimeoutTextBox";
      this.jscriptNetTimeoutTextBox.Size = new System.Drawing.Size(64, 20);
      this.jscriptNetTimeoutTextBox.TabIndex = 39;
      // 
      // label4
      // 
      this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.label4.Location = new System.Drawing.Point(6, 40);
      this.label4.Name = "label4";
      this.label4.Size = new System.Drawing.Size(112, 16);
      this.label4.TabIndex = 38;
      this.label4.Text = "JScript.NET timeout:";
      // 
      // activateCallerIdCheckBox
      // 
      this.activateCallerIdCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
      this.activateCallerIdCheckBox.Location = new System.Drawing.Point(14, 313);
      this.activateCallerIdCheckBox.Name = "activateCallerIdCheckBox";
      this.activateCallerIdCheckBox.Size = new System.Drawing.Size(120, 24);
      this.activateCallerIdCheckBox.TabIndex = 41;
      this.activateCallerIdCheckBox.Text = "Activate caller ID";
      // 
      // label5
      // 
      this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.label5.Location = new System.Drawing.Point(293, 64);
      this.label5.Name = "label5";
      this.label5.Size = new System.Drawing.Size(48, 16);
      this.label5.TabIndex = 44;
      this.label5.Text = "seconds";
      // 
      // queryTimeoutTextBox
      // 
      this.queryTimeoutTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.queryTimeoutTextBox.Location = new System.Drawing.Point(223, 62);
      this.queryTimeoutTextBox.Maximum = new decimal(new int[] {
            100000,
            0,
            0,
            0});
      this.queryTimeoutTextBox.Name = "queryTimeoutTextBox";
      this.queryTimeoutTextBox.Size = new System.Drawing.Size(64, 20);
      this.queryTimeoutTextBox.TabIndex = 43;
      // 
      // label6
      // 
      this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.label6.Location = new System.Drawing.Point(6, 64);
      this.label6.Name = "label6";
      this.label6.Size = new System.Drawing.Size(112, 16);
      this.label6.TabIndex = 42;
      this.label6.Text = "Query timeout:";
      // 
      // label7
      // 
      this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.label7.Location = new System.Drawing.Point(293, 88);
      this.label7.Name = "label7";
      this.label7.Size = new System.Drawing.Size(48, 16);
      this.label7.TabIndex = 47;
      this.label7.Text = "seconds";
      // 
      // loginTimeoutTextBox
      // 
      this.loginTimeoutTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.loginTimeoutTextBox.Location = new System.Drawing.Point(223, 86);
      this.loginTimeoutTextBox.Maximum = new decimal(new int[] {
            100000,
            0,
            0,
            0});
      this.loginTimeoutTextBox.Name = "loginTimeoutTextBox";
      this.loginTimeoutTextBox.Size = new System.Drawing.Size(64, 20);
      this.loginTimeoutTextBox.TabIndex = 46;
      // 
      // label8
      // 
      this.label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.label8.Location = new System.Drawing.Point(6, 88);
      this.label8.Name = "label8";
      this.label8.Size = new System.Drawing.Size(80, 16);
      this.label8.TabIndex = 45;
      this.label8.Text = "Login timeout:";
      // 
      // forceCaseSensitiveAuthenticationCheckBox
      // 
      this.forceCaseSensitiveAuthenticationCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
      this.forceCaseSensitiveAuthenticationCheckBox.Location = new System.Drawing.Point(14, 337);
      this.forceCaseSensitiveAuthenticationCheckBox.Name = "forceCaseSensitiveAuthenticationCheckBox";
      this.forceCaseSensitiveAuthenticationCheckBox.Size = new System.Drawing.Size(176, 24);
      this.forceCaseSensitiveAuthenticationCheckBox.TabIndex = 50;
      this.forceCaseSensitiveAuthenticationCheckBox.Text = "Case-sensitive authentication";
      // 
      // forceCaseSensitiveRolesCheckBox
      // 
      this.forceCaseSensitiveRolesCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
      this.forceCaseSensitiveRolesCheckBox.Location = new System.Drawing.Point(14, 361);
      this.forceCaseSensitiveRolesCheckBox.Name = "forceCaseSensitiveRolesCheckBox";
      this.forceCaseSensitiveRolesCheckBox.Size = new System.Drawing.Size(176, 24);
      this.forceCaseSensitiveRolesCheckBox.TabIndex = 49;
      this.forceCaseSensitiveRolesCheckBox.Text = "Case-sensitive role evaluation";
      // 
      // fireWhenchangedOnSubmitCheckBox
      // 
      this.fireWhenchangedOnSubmitCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
      this.fireWhenchangedOnSubmitCheckBox.Location = new System.Drawing.Point(192, 313);
      this.fireWhenchangedOnSubmitCheckBox.Name = "fireWhenchangedOnSubmitCheckBox";
      this.fireWhenchangedOnSubmitCheckBox.Size = new System.Drawing.Size(184, 24);
      this.fireWhenchangedOnSubmitCheckBox.TabIndex = 51;
      this.fireWhenchangedOnSubmitCheckBox.Text = "Fire \'When Changed\' on submit";
      // 
      // staticRoleResolutionCheckBox
      // 
      this.staticRoleResolutionCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
      this.staticRoleResolutionCheckBox.Location = new System.Drawing.Point(192, 337);
      this.staticRoleResolutionCheckBox.Name = "staticRoleResolutionCheckBox";
      this.staticRoleResolutionCheckBox.Size = new System.Drawing.Size(184, 24);
      this.staticRoleResolutionCheckBox.TabIndex = 52;
      this.staticRoleResolutionCheckBox.Text = "Static role resolution";
      // 
      // asyncJobsTextBox
      // 
      this.asyncJobsTextBox.Location = new System.Drawing.Point(245, 289);
      this.asyncJobsTextBox.Maximum = new decimal(new int[] {
            100000,
            0,
            0,
            0});
      this.asyncJobsTextBox.Name = "asyncJobsTextBox";
      this.asyncJobsTextBox.Size = new System.Drawing.Size(64, 20);
      this.asyncJobsTextBox.TabIndex = 54;
      // 
      // label9
      // 
      this.label9.Location = new System.Drawing.Point(10, 291);
      this.label9.Name = "label9";
      this.label9.Size = new System.Drawing.Size(229, 16);
      this.label9.TabIndex = 53;
      this.label9.Text = "Maximum simultaneous asynchronous jobs:";
      // 
      // allowGuestUserToRaiseFlagCheckBox
      // 
      this.allowGuestUserToRaiseFlagCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
      this.allowGuestUserToRaiseFlagCheckBox.Location = new System.Drawing.Point(192, 361);
      this.allowGuestUserToRaiseFlagCheckBox.Name = "allowGuestUserToRaiseFlagCheckBox";
      this.allowGuestUserToRaiseFlagCheckBox.Size = new System.Drawing.Size(256, 24);
      this.allowGuestUserToRaiseFlagCheckBox.TabIndex = 55;
      this.allowGuestUserToRaiseFlagCheckBox.Text = "Allow guest user to raise flags (version 7.0+)";
      // 
      // label10
      // 
      this.label10.Location = new System.Drawing.Point(8, 391);
      this.label10.Name = "label10";
      this.label10.Size = new System.Drawing.Size(80, 16);
      this.label10.TabIndex = 56;
      this.label10.Text = "Engine name:";
      // 
      // engineNameTextBox
      // 
      this.engineNameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                  | System.Windows.Forms.AnchorStyles.Right)));
      this.engineNameTextBox.Location = new System.Drawing.Point(88, 391);
      this.engineNameTextBox.Name = "engineNameTextBox";
      this.engineNameTextBox.Size = new System.Drawing.Size(574, 20);
      this.engineNameTextBox.TabIndex = 57;
      this.engineNameTextBox.Text = "engineNameTextBox";
      // 
      // label11
      // 
      this.label11.Location = new System.Drawing.Point(8, 415);
      this.label11.Name = "label11";
      this.label11.Size = new System.Drawing.Size(64, 16);
      this.label11.TabIndex = 58;
      this.label11.Text = "Base URL:";
      // 
      // baseUrlTextBox
      // 
      this.baseUrlTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                  | System.Windows.Forms.AnchorStyles.Right)));
      this.baseUrlTextBox.Location = new System.Drawing.Point(88, 415);
      this.baseUrlTextBox.Name = "baseUrlTextBox";
      this.baseUrlTextBox.Size = new System.Drawing.Size(574, 20);
      this.baseUrlTextBox.TabIndex = 59;
      this.baseUrlTextBox.Text = "baseUrlTextBox";
      // 
      // logToFileCheckBox
      // 
      this.logToFileCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
      this.logToFileCheckBox.Location = new System.Drawing.Point(14, 441);
      this.logToFileCheckBox.Name = "logToFileCheckBox";
      this.logToFileCheckBox.Size = new System.Drawing.Size(192, 16);
      this.logToFileCheckBox.TabIndex = 60;
      this.logToFileCheckBox.Text = "Log event log entries to a text file";
      this.logToFileCheckBox.CheckedChanged += new System.EventHandler(this.logToFileCheckBox_CheckedChanged);
      // 
      // label12
      // 
      this.label12.Location = new System.Drawing.Point(11, 460);
      this.label12.Name = "label12";
      this.label12.Size = new System.Drawing.Size(72, 16);
      this.label12.TabIndex = 61;
      this.label12.Text = "Event log file:";
      // 
      // eventLogFileTextBox
      // 
      this.eventLogFileTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                  | System.Windows.Forms.AnchorStyles.Right)));
      this.eventLogFileTextBox.Location = new System.Drawing.Point(88, 457);
      this.eventLogFileTextBox.Name = "eventLogFileTextBox";
      this.eventLogFileTextBox.Size = new System.Drawing.Size(574, 20);
      this.eventLogFileTextBox.TabIndex = 62;
      this.eventLogFileTextBox.Text = "eventLogFileTextBox";
      // 
      // precompileCheckBox
      // 
      this.precompileCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
      this.precompileCheckBox.Location = new System.Drawing.Point(14, 489);
      this.precompileCheckBox.Name = "precompileCheckBox";
      this.precompileCheckBox.Size = new System.Drawing.Size(184, 16);
      this.precompileCheckBox.TabIndex = 63;
      this.precompileCheckBox.Text = "Precompile JScript.NET scripts";
      // 
      // infoLabel
      // 
      this.infoLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                  | System.Windows.Forms.AnchorStyles.Right)));
      this.infoLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.infoLabel.Location = new System.Drawing.Point(360, 46);
      this.infoLabel.Name = "infoLabel";
      this.infoLabel.Size = new System.Drawing.Size(298, 101);
      this.infoLabel.TabIndex = 64;
      this.infoLabel.Text = "Any changes made here will affect the engine running on this machine. You may nee" +
          "d to restart the engine for the changes to take effect";
      // 
      // engineStatusLabel
      // 
      this.engineStatusLabel.Location = new System.Drawing.Point(9, 542);
      this.engineStatusLabel.Name = "engineStatusLabel";
      this.engineStatusLabel.Size = new System.Drawing.Size(344, 16);
      this.engineStatusLabel.TabIndex = 65;
      this.engineStatusLabel.Text = "Engine status:";
      // 
      // label13
      // 
      this.label13.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.label13.Location = new System.Drawing.Point(293, 111);
      this.label13.Name = "label13";
      this.label13.Size = new System.Drawing.Size(48, 16);
      this.label13.TabIndex = 68;
      this.label13.Text = "seconds";
      // 
      // wfTimeoutTextBox
      // 
      this.wfTimeoutTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.wfTimeoutTextBox.Location = new System.Drawing.Point(223, 109);
      this.wfTimeoutTextBox.Maximum = new decimal(new int[] {
            100000,
            0,
            0,
            0});
      this.wfTimeoutTextBox.Name = "wfTimeoutTextBox";
      this.wfTimeoutTextBox.Size = new System.Drawing.Size(64, 20);
      this.wfTimeoutTextBox.TabIndex = 67;
      // 
      // label14
      // 
      this.label14.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.label14.Location = new System.Drawing.Point(6, 111);
      this.label14.Name = "label14";
      this.label14.Size = new System.Drawing.Size(218, 16);
      this.label14.TabIndex = 66;
      this.label14.Text = "Windows Workflow timeout (version 7.6+):";
      // 
      // alertGeneratorBatchLabel
      // 
      this.alertGeneratorBatchLabel.AutoSize = true;
      this.alertGeneratorBatchLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.alertGeneratorBatchLabel.Location = new System.Drawing.Point(6, 45);
      this.alertGeneratorBatchLabel.Name = "alertGeneratorBatchLabel";
      this.alertGeneratorBatchLabel.Size = new System.Drawing.Size(159, 13);
      this.alertGeneratorBatchLabel.TabIndex = 0;
      this.alertGeneratorBatchLabel.Text = "Batch size threshhold for thread:";
      // 
      // alertGeneratorBatchSize
      // 
      this.alertGeneratorBatchSize.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.alertGeneratorBatchSize.Location = new System.Drawing.Point(181, 43);
      this.alertGeneratorBatchSize.Maximum = new decimal(new int[] {
            100000,
            0,
            0,
            0});
      this.alertGeneratorBatchSize.Name = "alertGeneratorBatchSize";
      this.alertGeneratorBatchSize.Size = new System.Drawing.Size(64, 20);
      this.alertGeneratorBatchSize.TabIndex = 68;
      // 
      // alertGeneratorEnabled
      // 
      this.alertGeneratorEnabled.AutoSize = true;
      this.alertGeneratorEnabled.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.alertGeneratorEnabled.Location = new System.Drawing.Point(9, 23);
      this.alertGeneratorEnabled.Name = "alertGeneratorEnabled";
      this.alertGeneratorEnabled.Size = new System.Drawing.Size(65, 17);
      this.alertGeneratorEnabled.TabIndex = 69;
      this.alertGeneratorEnabled.Text = "Enabled";
      this.alertGeneratorEnabled.UseVisualStyleBackColor = true;
      this.alertGeneratorEnabled.CheckedChanged += new System.EventHandler(this.alertGeneratorEnabled_CheckedChanged);
      // 
      // alertGeneratorPollLabel
      // 
      this.alertGeneratorPollLabel.AutoSize = true;
      this.alertGeneratorPollLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.alertGeneratorPollLabel.Location = new System.Drawing.Point(6, 71);
      this.alertGeneratorPollLabel.Name = "alertGeneratorPollLabel";
      this.alertGeneratorPollLabel.Size = new System.Drawing.Size(96, 13);
      this.alertGeneratorPollLabel.TabIndex = 70;
      this.alertGeneratorPollLabel.Text = "Poll Interval (secs):";
      // 
      // alertGeneratorPollInterval
      // 
      this.alertGeneratorPollInterval.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.alertGeneratorPollInterval.Location = new System.Drawing.Point(181, 69);
      this.alertGeneratorPollInterval.Maximum = new decimal(new int[] {
            100000,
            0,
            0,
            0});
      this.alertGeneratorPollInterval.Name = "alertGeneratorPollInterval";
      this.alertGeneratorPollInterval.Size = new System.Drawing.Size(64, 20);
      this.alertGeneratorPollInterval.TabIndex = 71;
      // 
      // alertGeneratorThreadLabel
      // 
      this.alertGeneratorThreadLabel.AutoSize = true;
      this.alertGeneratorThreadLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.alertGeneratorThreadLabel.Location = new System.Drawing.Point(7, 95);
      this.alertGeneratorThreadLabel.Name = "alertGeneratorThreadLabel";
      this.alertGeneratorThreadLabel.Size = new System.Drawing.Size(74, 13);
      this.alertGeneratorThreadLabel.TabIndex = 72;
      this.alertGeneratorThreadLabel.Text = "Thread count:";
      // 
      // alertGeneratorThreadCount
      // 
      this.alertGeneratorThreadCount.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.alertGeneratorThreadCount.Location = new System.Drawing.Point(181, 93);
      this.alertGeneratorThreadCount.Maximum = new decimal(new int[] {
            100000,
            0,
            0,
            0});
      this.alertGeneratorThreadCount.Name = "alertGeneratorThreadCount";
      this.alertGeneratorThreadCount.Size = new System.Drawing.Size(64, 20);
      this.alertGeneratorThreadCount.TabIndex = 73;
      // 
      // eventManagerThreadCount
      // 
      this.eventManagerThreadCount.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.eventManagerThreadCount.Location = new System.Drawing.Point(183, 95);
      this.eventManagerThreadCount.Maximum = new decimal(new int[] {
            100000,
            0,
            0,
            0});
      this.eventManagerThreadCount.Name = "eventManagerThreadCount";
      this.eventManagerThreadCount.Size = new System.Drawing.Size(64, 20);
      this.eventManagerThreadCount.TabIndex = 73;
      // 
      // eventManagerThreadLabel
      // 
      this.eventManagerThreadLabel.AutoSize = true;
      this.eventManagerThreadLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.eventManagerThreadLabel.Location = new System.Drawing.Point(6, 97);
      this.eventManagerThreadLabel.Name = "eventManagerThreadLabel";
      this.eventManagerThreadLabel.Size = new System.Drawing.Size(74, 13);
      this.eventManagerThreadLabel.TabIndex = 72;
      this.eventManagerThreadLabel.Text = "Thread count:";
      // 
      // eventManagerPollInterval
      // 
      this.eventManagerPollInterval.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.eventManagerPollInterval.Location = new System.Drawing.Point(183, 69);
      this.eventManagerPollInterval.Maximum = new decimal(new int[] {
            100000,
            0,
            0,
            0});
      this.eventManagerPollInterval.Name = "eventManagerPollInterval";
      this.eventManagerPollInterval.Size = new System.Drawing.Size(64, 20);
      this.eventManagerPollInterval.TabIndex = 71;
      // 
      // eventManagerPollLabel
      // 
      this.eventManagerPollLabel.AutoSize = true;
      this.eventManagerPollLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.eventManagerPollLabel.Location = new System.Drawing.Point(5, 71);
      this.eventManagerPollLabel.Name = "eventManagerPollLabel";
      this.eventManagerPollLabel.Size = new System.Drawing.Size(96, 13);
      this.eventManagerPollLabel.TabIndex = 70;
      this.eventManagerPollLabel.Text = "Poll Interval (secs):";
      // 
      // eventManagerEnabled
      // 
      this.eventManagerEnabled.AutoSize = true;
      this.eventManagerEnabled.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.eventManagerEnabled.Location = new System.Drawing.Point(8, 23);
      this.eventManagerEnabled.Name = "eventManagerEnabled";
      this.eventManagerEnabled.Size = new System.Drawing.Size(65, 17);
      this.eventManagerEnabled.TabIndex = 69;
      this.eventManagerEnabled.Text = "Enabled";
      this.eventManagerEnabled.UseVisualStyleBackColor = true;
      this.eventManagerEnabled.CheckedChanged += new System.EventHandler(this.eventManagerEnabled_CheckedChanged);
      // 
      // eventManagerBatchSize
      // 
      this.eventManagerBatchSize.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.eventManagerBatchSize.Location = new System.Drawing.Point(183, 43);
      this.eventManagerBatchSize.Maximum = new decimal(new int[] {
            100000,
            0,
            0,
            0});
      this.eventManagerBatchSize.Name = "eventManagerBatchSize";
      this.eventManagerBatchSize.Size = new System.Drawing.Size(64, 20);
      this.eventManagerBatchSize.TabIndex = 68;
      // 
      // eventManagerBatchLabel
      // 
      this.eventManagerBatchLabel.AutoSize = true;
      this.eventManagerBatchLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.eventManagerBatchLabel.Location = new System.Drawing.Point(5, 45);
      this.eventManagerBatchLabel.Name = "eventManagerBatchLabel";
      this.eventManagerBatchLabel.Size = new System.Drawing.Size(159, 13);
      this.eventManagerBatchLabel.TabIndex = 0;
      this.eventManagerBatchLabel.Text = "Batch size threshhold for thread:";
      // 
      // xtraScrollableControl1
      // 
      this.xtraScrollableControl1.Controls.Add(this.emailConnectionString);
      this.xtraScrollableControl1.Controls.Add(this.label15);
      this.xtraScrollableControl1.Controls.Add(this.groupControl3);
      this.xtraScrollableControl1.Controls.Add(this.groupControl2);
      this.xtraScrollableControl1.Controls.Add(this.groupControl1);
      this.xtraScrollableControl1.Controls.Add(this.engineStatusLabel);
      this.xtraScrollableControl1.Controls.Add(this.precompileCheckBox);
      this.xtraScrollableControl1.Controls.Add(this.infoLabel);
      this.xtraScrollableControl1.Controls.Add(this.eventLogFileTextBox);
      this.xtraScrollableControl1.Controls.Add(this.label9);
      this.xtraScrollableControl1.Controls.Add(this.label12);
      this.xtraScrollableControl1.Controls.Add(this.asyncJobsTextBox);
      this.xtraScrollableControl1.Controls.Add(this.logToFileCheckBox);
      this.xtraScrollableControl1.Controls.Add(this.pictureBox1);
      this.xtraScrollableControl1.Controls.Add(this.baseUrlTextBox);
      this.xtraScrollableControl1.Controls.Add(this.fireWhenchangedOnSubmitCheckBox);
      this.xtraScrollableControl1.Controls.Add(this.label11);
      this.xtraScrollableControl1.Controls.Add(this.activateCallerIdCheckBox);
      this.xtraScrollableControl1.Controls.Add(this.engineNameTextBox);
      this.xtraScrollableControl1.Controls.Add(this.label10);
      this.xtraScrollableControl1.Controls.Add(this.forceCaseSensitiveAuthenticationCheckBox);
      this.xtraScrollableControl1.Controls.Add(this.forceCaseSensitiveRolesCheckBox);
      this.xtraScrollableControl1.Controls.Add(this.allowGuestUserToRaiseFlagCheckBox);
      this.xtraScrollableControl1.Controls.Add(this.staticRoleResolutionCheckBox);
      this.xtraScrollableControl1.Dock = System.Windows.Forms.DockStyle.Fill;
      this.xtraScrollableControl1.Location = new System.Drawing.Point(0, 0);
      this.xtraScrollableControl1.Name = "xtraScrollableControl1";
      this.xtraScrollableControl1.Size = new System.Drawing.Size(670, 656);
      this.xtraScrollableControl1.TabIndex = 72;
      // 
      // groupControl3
      // 
      this.groupControl3.Controls.Add(this.alertGeneratorThreadCount);
      this.groupControl3.Controls.Add(this.alertGeneratorPollInterval);
      this.groupControl3.Controls.Add(this.alertGeneratorThreadLabel);
      this.groupControl3.Controls.Add(this.alertGeneratorBatchLabel);
      this.groupControl3.Controls.Add(this.alertGeneratorBatchSize);
      this.groupControl3.Controls.Add(this.alertGeneratorPollLabel);
      this.groupControl3.Controls.Add(this.alertGeneratorEnabled);
      this.groupControl3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.groupControl3.Location = new System.Drawing.Point(273, 153);
      this.groupControl3.Name = "groupControl3";
      this.groupControl3.Size = new System.Drawing.Size(267, 126);
      this.groupControl3.TabIndex = 74;
      this.groupControl3.TabStop = false;
      this.groupControl3.Text = "Alert generator";
      // 
      // groupControl2
      // 
      this.groupControl2.Controls.Add(this.eventManagerThreadCount);
      this.groupControl2.Controls.Add(this.eventManagerEnabled);
      this.groupControl2.Controls.Add(this.eventManagerThreadLabel);
      this.groupControl2.Controls.Add(this.eventManagerBatchLabel);
      this.groupControl2.Controls.Add(this.eventManagerPollInterval);
      this.groupControl2.Controls.Add(this.eventManagerBatchSize);
      this.groupControl2.Controls.Add(this.eventManagerPollLabel);
      this.groupControl2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.groupControl2.Location = new System.Drawing.Point(5, 153);
      this.groupControl2.Name = "groupControl2";
      this.groupControl2.Size = new System.Drawing.Size(262, 126);
      this.groupControl2.TabIndex = 73;
      this.groupControl2.TabStop = false;
      this.groupControl2.Text = "Event manager";
      // 
      // groupControl1
      // 
      this.groupControl1.Controls.Add(this.jscriptNetTimeoutTextBox);
      this.groupControl1.Controls.Add(this.label6);
      this.groupControl1.Controls.Add(this.label7);
      this.groupControl1.Controls.Add(this.label13);
      this.groupControl1.Controls.Add(this.loginTimeoutTextBox);
      this.groupControl1.Controls.Add(this.label1);
      this.groupControl1.Controls.Add(this.label8);
      this.groupControl1.Controls.Add(this.label5);
      this.groupControl1.Controls.Add(this.wfTimeoutTextBox);
      this.groupControl1.Controls.Add(this.queryTimeoutTextBox);
      this.groupControl1.Controls.Add(this.label3);
      this.groupControl1.Controls.Add(this.scriptTimeoutTextBox);
      this.groupControl1.Controls.Add(this.label4);
      this.groupControl1.Controls.Add(this.label2);
      this.groupControl1.Controls.Add(this.label14);
      this.groupControl1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.groupControl1.Location = new System.Drawing.Point(5, 9);
      this.groupControl1.Name = "groupControl1";
      this.groupControl1.Size = new System.Drawing.Size(349, 138);
      this.groupControl1.TabIndex = 72;
      this.groupControl1.TabStop = false;
      this.groupControl1.Text = "Timeouts";
      // 
      // label15
      // 
      this.label15.AutoSize = true;
      this.label15.Location = new System.Drawing.Point(9, 518);
      this.label15.Name = "label15";
      this.label15.Size = new System.Drawing.Size(119, 13);
      this.label15.TabIndex = 75;
      this.label15.Text = "Email connection string:";
      // 
      // emailConnectionString
      // 
      this.emailConnectionString.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                  | System.Windows.Forms.AnchorStyles.Right)));
      this.emailConnectionString.Location = new System.Drawing.Point(135, 515);
      this.emailConnectionString.Name = "emailConnectionString";
      this.emailConnectionString.Size = new System.Drawing.Size(527, 20);
      this.emailConnectionString.TabIndex = 76;
      this.emailConnectionString.Text = "emailConnectionString";
      // 
      // uiActionsControl
      // 
      this.uiActionsControl.Actions = null;
      this.uiActionsControl.Dock = System.Windows.Forms.DockStyle.Right;
      this.uiActionsControl.Location = new System.Drawing.Point(670, 0);
      this.uiActionsControl.Name = "uiActionsControl";
      this.uiActionsControl.Size = new System.Drawing.Size(150, 656);
      this.uiActionsControl.TabIndex = 0;
      // 
      // RegistrySettingsControl
      // 
      this.Controls.Add(this.xtraScrollableControl1);
      this.Controls.Add(this.uiActionsControl);
      this.Name = "RegistrySettingsControl";
      this.Size = new System.Drawing.Size(820, 656);
      ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
      ((System.ComponentModel.ISupportInitialize)(this.scriptTimeoutTextBox)).EndInit();
      ((System.ComponentModel.ISupportInitialize)(this.jscriptNetTimeoutTextBox)).EndInit();
      ((System.ComponentModel.ISupportInitialize)(this.queryTimeoutTextBox)).EndInit();
      ((System.ComponentModel.ISupportInitialize)(this.loginTimeoutTextBox)).EndInit();
      ((System.ComponentModel.ISupportInitialize)(this.asyncJobsTextBox)).EndInit();
      ((System.ComponentModel.ISupportInitialize)(this.wfTimeoutTextBox)).EndInit();
      ((System.ComponentModel.ISupportInitialize)(this.alertGeneratorBatchSize)).EndInit();
      ((System.ComponentModel.ISupportInitialize)(this.alertGeneratorPollInterval)).EndInit();
      ((System.ComponentModel.ISupportInitialize)(this.alertGeneratorThreadCount)).EndInit();
      ((System.ComponentModel.ISupportInitialize)(this.eventManagerThreadCount)).EndInit();
      ((System.ComponentModel.ISupportInitialize)(this.eventManagerPollInterval)).EndInit();
      ((System.ComponentModel.ISupportInitialize)(this.eventManagerBatchSize)).EndInit();
      this.xtraScrollableControl1.ResumeLayout(false);
      this.xtraScrollableControl1.PerformLayout();
      this.groupControl3.ResumeLayout(false);
      this.groupControl3.PerformLayout();
      this.groupControl2.ResumeLayout(false);
      this.groupControl2.PerformLayout();
      this.groupControl1.ResumeLayout(false);
      this.ResumeLayout(false);

    }
		#endregion

    private string ApplyChanges()
    {
      try
      {
        registrySettings.ScriptTimeout = Convert.ToInt32(scriptTimeoutTextBox.Value);
        registrySettings.JScriptNetScriptTimeout = Convert.ToInt32(jscriptNetTimeoutTextBox.Value);
        registrySettings.ActivateCallerId = activateCallerIdCheckBox.Checked;
        registrySettings.QueryTimeout = Convert.ToInt32(queryTimeoutTextBox.Value);
        registrySettings.LoginTimeout = Convert.ToInt32(loginTimeoutTextBox.Value);
        registrySettings.CaseSensitiveAuthentication = forceCaseSensitiveAuthenticationCheckBox.Checked;
        registrySettings.CaseSensitiveRoleEvaluation = forceCaseSensitiveRolesCheckBox.Checked;
        registrySettings.FireWhenChangedOnSubmit = fireWhenchangedOnSubmitCheckBox.Checked;
        registrySettings.StaticRoleResolution = staticRoleResolutionCheckBox.Checked;
        registrySettings.MaximumSimultaneousAsynchronousJobs = Convert.ToInt32(asyncJobsTextBox.Value);
        registrySettings.AllowGuestUserToRaiseFlag = allowGuestUserToRaiseFlagCheckBox.Checked;
        registrySettings.EngineName = engineNameTextBox.Text;
        registrySettings.BaseUrl = baseUrlTextBox.Text;
        registrySettings.LogEventLogEntriesToFile = logToFileCheckBox.Checked;
        registrySettings.LogFile = eventLogFileTextBox.Text;
        registrySettings.PrecompileJScriptNet = precompileCheckBox.Checked;
        registrySettings.WorkflowTimeout = Convert.ToInt32(wfTimeoutTextBox.Value);
        registrySettings.EmailConnectionString = emailConnectionString.Text;

        // event manager
        registrySettings.EventManagerEnabled = eventManagerEnabled.Checked;
        registrySettings.EventManagerBatchSize = Convert.ToInt32(eventManagerBatchSize.Value);
        registrySettings.EventManagerPollInterval = Convert.ToInt32(eventManagerPollInterval.Value);
        registrySettings.EventManagerThreadCount = Convert.ToInt32(eventManagerThreadCount.Value);

        // alert generator
        registrySettings.AlertGeneratorEnabled = alertGeneratorEnabled.Checked;
        registrySettings.AlertGeneratorBatchSize = Convert.ToInt32(alertGeneratorBatchSize.Value);
        registrySettings.AlertGeneratorPollInterval = Convert.ToInt32(alertGeneratorPollInterval.Value);
        registrySettings.AlertGeneratorThreadCount = Convert.ToInt32(alertGeneratorThreadCount.Value);

        return Constants.ChangesApplied;
      }
      catch (UnauthorizedAccessException)
      {
        return "You do not have the required rights to update the registry on this machine";
      }
    }

    private string RunRegEdit()
    {
      Process.Start("regedit");
      return "";
    }

    private string RunEventViewer()
    {
      Process.Start("eventvwr.msc");
      return "";
    }

    delegate void WaitForStatusDelegate(ServiceControllerStatus status);

    private string StartEngine()
    {
      if ((engineService != null) && (engineService.Status != ServiceControllerStatus.StartPending))
      {
        engineStatusLabel.Text = "Engine status: Starting";
        engineService.Start();
        
        // Wait for the engine to start
        WaitForStatusDelegate statusDelegate = new WaitForStatusDelegate(WaitForStatus); 
        statusDelegate.BeginInvoke(ServiceControllerStatus.Running, new AsyncCallback(WaitedCallBack), null); 
      }
      return "Starting engine";
    }

    private string StopEngine()
    {
      if ((engineService != null) && (engineService.Status != ServiceControllerStatus.StopPending))
      {
        engineStatusLabel.Text = "Engine status: Stopping";
        engineService.Stop();

        // Wait for the engine to start
        WaitForStatusDelegate statusDelegate = new WaitForStatusDelegate(WaitForStatus); 
        statusDelegate.BeginInvoke(ServiceControllerStatus.Stopped, new AsyncCallback(WaitedCallBack), null); 
      }
      return "Stopping engine";
    }

    private void WaitForStatus(ServiceControllerStatus status)
    {
      engineService.WaitForStatus(status);
    }

    private void WaitedCallBack(IAsyncResult result)
    {
      if (InvokeRequired)
      {
        Invoke(new AsyncCallback(WaitedCallBack), new object[] {result});
      }
      else
      {
        WaitForStatusDelegate logDelegate = (WaitForStatusDelegate)((AsyncResult)result).AsyncDelegate;
        logDelegate.EndInvoke(result);
        ShowEngineStatus();
        UpdateActions();
        uiActionsControl.SetFeedback("");
      }
    }

    private void logToFileCheckBox_CheckedChanged(object sender, EventArgs e)
    {
      EnableLogTextBox();
    }

    private void EnableLogTextBox()
    {
      eventLogFileTextBox.Enabled = logToFileCheckBox.Checked;
    }

    private void eventManagerEnabled_CheckedChanged(object sender, EventArgs e)
    {
      EnableEventManager();
    }

    private void EnableEventManager()
    {
      eventManagerBatchSize.Enabled = eventManagerEnabled.Checked;
      eventManagerBatchLabel.Enabled = eventManagerEnabled.Checked;
      eventManagerPollInterval.Enabled = eventManagerEnabled.Checked;
      eventManagerPollLabel.Enabled = eventManagerEnabled.Checked;
      eventManagerThreadCount.Enabled = eventManagerEnabled.Checked;
      eventManagerThreadLabel.Enabled = eventManagerEnabled.Checked;
    }

    private void alertGeneratorEnabled_CheckedChanged(object sender, EventArgs e)
    {
      EnableAlertGenerator();
    }

    private void EnableAlertGenerator()
    {
      alertGeneratorBatchSize.Enabled = alertGeneratorEnabled.Checked;
      alertGeneratorBatchLabel.Enabled = alertGeneratorEnabled.Checked;
      alertGeneratorPollInterval.Enabled = alertGeneratorEnabled.Checked;
      alertGeneratorPollLabel.Enabled = alertGeneratorEnabled.Checked;
      alertGeneratorThreadCount.Enabled = alertGeneratorEnabled.Checked;
      alertGeneratorThreadLabel.Enabled = alertGeneratorEnabled.Checked;
    }
	}
}
